-
Notifications
You must be signed in to change notification settings - Fork 111
Fix new_window
argument typing in Session
#596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix new_window
argument typing in Session
#596
Conversation
Reviewer's GuideThis PR fixes the Updated Class Diagram for Session.new_window Method SignatureclassDiagram
class Session {
+new_window(window_name: str | None, start_directory: str | None, attach: bool, window_index: str, window_shell: str | None, environment: dict[str, str] | None) Window
}
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Data5tream - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
f7e5788
to
09de00a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good catch!
I will follow up with in https://github.com/tmux-python/libtmux/pull/596/files#r2106995968 in a PR before cutting a new release.
I'm making mistakes, but follow up to #597, #596 ## Summary This PR adds uniform `StrPath` type support for `start_directory` parameters across all methods in libtmux, enabling PathLike objects (like `pathlib.Path`) to be used alongside strings. ## Changes Made ### Type Annotations Updated - `Server.new_session`: `start_directory: str | None` → `start_directory: StrPath | None` - `Session.new_window`: `start_directory: str | None` → `start_directory: StrPath | None` - `Pane.split` and `Pane.split_window`: `start_directory: str | None` → `start_directory: StrPath | None` - `Window.split` and `Window.split_window`: `start_directory: str | None` → `start_directory: StrPath | None` ### Implementation Details - Added `StrPath` import to all affected modules - Updated docstrings to reflect "str or PathLike" support - Standardized logic patterns using `if start_directory:` (not `if start_directory is not None:`) to properly handle empty strings - Added path expansion logic with `pathlib.Path(start_directory).expanduser()` for proper tilde expansion ### Testing - Added comprehensive parametrized tests for all affected methods - Test cases cover: `None`, empty string, absolute path string, and `pathlib.Path` objects - Added separate pathlib-specific tests using temporary directories - Tests verify operations complete successfully with all input types - Integrated tests into existing test files following project conventions
@Data5tream Live in v0.46.2 (PyPI, Release, Changelog) |
Corrects the
start_directory
type of thenew_window
method on theSession
class.Fixes #595
Summary by Sourcery
Fix the typing and conditional handling of the
start_directory
argument inSession.new_window
to accept string paths and avoid skipping valid values.Bug Fixes:
start_directory
annotation tostr | None
inSession.new_window
if start_directory is not None
so empty strings aren’t misinterpreted as absent paths